//package com.qujia.station.controller;
//
//import java.math.BigDecimal;
//import java.util.List;
//
//import com.qujia.common.core.domain.entity.SysDept;
//import com.qujia.common.core.domain.model.LoginUser;
//import com.qujia.common.utils.DateUtils;
//import com.qujia.common.utils.SecurityUtils;
//import com.qujia.system.service.ISysDeptService;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.transaction.annotation.Transactional;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.PutMapping;
//import org.springframework.web.bind.annotation.DeleteMapping;
//import org.springframework.web.bind.annotation.PathVariable;
//import org.springframework.web.bind.annotation.RequestBody;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//import com.qujia.common.annotation.Log;
//import com.qujia.common.core.controller.BaseController;
//import com.qujia.common.core.domain.AjaxResult;
//import com.qujia.common.enums.BusinessType;
//import com.qujia.station.domain.StationBalanceChange;
//import com.qujia.station.service.IStationBalanceChangeService;
//import com.qujia.common.utils.poi.ExcelUtil;
//import com.qujia.common.core.page.TableDataInfo;
//
///**
// * LNG油站余额变化记录Controller
// *
// * @author qujia
// * @date 2021-07-13
// */
//@RestController
//@RequestMapping("/station/stationBalanceChange")
//public class StationBalanceChangeController extends BaseController
//{
//    @Autowired
//    private IStationBalanceChangeService stationBalanceChangeService;
//    @Autowired
//    private ISysDeptService deptService;
//    /**
//     * 查询LNG油站余额变化记录列表
//     */
//    @GetMapping("/list")
//    public TableDataInfo list(StationBalanceChange stationBalanceChange)
//    {
//        List<String> list = deptService.levelDeptList(stationBalanceChange.getLevelId());
//        if(list!=null && list.size()>0){
//            stationBalanceChange.setStationIdList(list);
//            stationBalanceChange.setStationId(null);
//        }
//        startPage();
//        List<StationBalanceChange> changeList = stationBalanceChangeService.selectStationBalanceChangeList(stationBalanceChange);
//        return getDataTable(changeList);
//    }
//
//    /**
//     * 导出LNG油站余额变化记录列表
//     */
//    @Log(title = "LNG油站余额变化记录", businessType = BusinessType.EXPORT)
//    @GetMapping("/export")
//    public AjaxResult export(StationBalanceChange stationBalanceChange)
//    {
//        List<String> list = deptService.levelDeptList(stationBalanceChange.getLevelId());
//        if(list!=null && list.size()>0){
//            stationBalanceChange.setStationIdList(list);
//            stationBalanceChange.setStationId(null);
//        }
//        List<StationBalanceChange> changeList = stationBalanceChangeService.selectStationBalanceChangeList(stationBalanceChange);
//        ExcelUtil<StationBalanceChange> util = new ExcelUtil<StationBalanceChange>(StationBalanceChange.class);
//        return util.exportExcel(changeList, "change");
//    }
//
//    /**
//     * 获取LNG油站余额变化记录详细信息
//     */
//     @GetMapping(value = "/{id}")
//    public AjaxResult getInfo(@PathVariable("id") Long id)
//    {
//        return AjaxResult.success(stationBalanceChangeService.selectStationBalanceChangeById(id));
//    }
//
//    /**
//     * 新增LNG油站余额变化记录
//     */
//    @Log(title = "LNG油站余额变化记录", businessType = BusinessType.INSERT)
//    @PostMapping("/add")
//    @Transactional
//    public AjaxResult add(@RequestBody StationBalanceChange stationBalanceChange)
//    {
//        int i=0;
//        //获取当前站上余额是多少
//        LoginUser currentUser = SecurityUtils.getLoginUser();
//        if(stationBalanceChange.getStationId()!=null && stationBalanceChange.getAmt()!=null && stationBalanceChange.getType()!=null){
//            SysDept dept =deptService.selectDeptById(stationBalanceChange.getStationId());
//            stationBalanceChange.setNowAmt(dept.getBalance());
//            if(dept!=null){
//                if( dept.getBalance()!=null){
//                    if(stationBalanceChange.getType().equals("+")){
//                        dept.setBalance(dept.getBalance().add(stationBalanceChange.getAmt()));
//                    }else if(stationBalanceChange.getType().equals("-")){
//                        dept.setBalance(dept.getBalance().subtract(stationBalanceChange.getAmt()));
//                    }
//                }else  {
//                    if(stationBalanceChange.getType().equals("+")){
//                        dept.setBalance(stationBalanceChange.getAmt());
//                    }else if(stationBalanceChange.getType().equals("-")){
//                        dept.setBalance(new BigDecimal("0").subtract(stationBalanceChange.getAmt()));
//                    }
//                }
//                i = deptService.updateDeptInfo(dept);
//                stationBalanceChange.setCreateBy(currentUser.getUser().getUserId()+"");
//                stationBalanceChange.setCreateTime(DateUtils.getNowDate());
//                i = stationBalanceChangeService.insertStationBalanceChange(stationBalanceChange);
//            }else{
//                logger.debug("没有查询到站点信息");
//            }
//        }
//        return toAjax(i);
//    }
//
//    /**
//     * 修改LNG油站余额变化记录
//     */
//    @Log(title = "LNG油站余额变化记录", businessType = BusinessType.UPDATE)
//    @PutMapping
//    public AjaxResult edit(@RequestBody StationBalanceChange stationBalanceChange)
//    {
//        return toAjax(stationBalanceChangeService.updateStationBalanceChange(stationBalanceChange));
//    }
//
//    /**
//     * 删除LNG油站余额变化记录
//     */
//    @Log(title = "LNG油站余额变化记录", businessType = BusinessType.DELETE)
//	@DeleteMapping("/{ids}")
//    public AjaxResult remove(@PathVariable Long[] ids)
//    {
//        return toAjax(stationBalanceChangeService.deleteStationBalanceChangeByIds(ids));
//    }
//}
